﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using JYStockAnalyser.Model;
using JYStockAnalyser.Face;
using JYStockAnalyser.ClientLib;

namespace JYStockAnalyser.Manager
{
    public partial class FrmAddUser : Form
    {
        public FrmAddUser()
        {
            InitializeComponent();
        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (userEditor1.Vali())
            {
                User user = this.userEditor1.GetUser();
                UserManageFace face = new UserManageFace();
                try
                {
                    face.AddUser(user.UserName, user.Name, user.Password, user.Sex, user.Work, user.ContractNO, user.Email, user.EndDate, user.IsGuest);
                    Tool.ShowInformationBox("添加成功!");
                    this.DialogResult = DialogResult.Yes;
                    this.Close();
                }
                catch (PropertiesExistsException)
                {
                    Tool.ShowInformationBox("用户名已存在!");                    
                }
            }
          
        }
    }
}
